package com.example.server.controller;

import com.example.commons.MsgPool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/cmd")
public class CmdController {

    @Autowired
    private MsgPool pool;

    @RequestMapping("hello")
    public Object hello(@RequestParam String clientId, @RequestParam String data) {

        try {
            return pool.sendMsgToClient(clientId, data);
        } catch (RuntimeException e) {
            return e.getMessage();
        }
    }
}
